/*----------------------------------------------------------------------
  - File name      : button.c
  - Author         : Liu Chao
  - Update date    : 2020-10-10                   
  -	Copyright      : Gevico Electronic studio   
  - Module comments: 
-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/
#include "button.h"
#include "main.h"
#include "pwm.h"
/*-----------------------------------------------------------------------
|                                 DATA                                  |
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
|                               FUNCTION                                |
-----------------------------------------------------------------------*/

/*--------------------------------------------------------
| @Description: Principal function                       |
| @param      : None                                     |
| @return     : None                                     |
--------------------------------------------------------*/
void button_handler(void)
{
  static uint16_t ReadData; 
	static uint8_t PWMDat;
	
	ReadData = Key_Scan_One(GPIOA,KEY_STATE_SING);
	
	if(ReadData & KEY_UP_PIN)   
	{
		PWMDat = (PWMDat+5) % 25;
		Run_Lamp();
		PWM_Out(PWMDat);  
	}
	
	if(ReadData & KEY_DOWN_PIN)
	{
		PWMDat -= 5;
		Run_Lamp();
		PWM_Out(PWMDat);
	}

}


/*-----------------------------------------------------------------------
|          END OF FLIE        (C) COPYRIGHT Gevico Electronics          | 
-----------------------------------------------------------------------*/

